<template>
	<el-dialog width="500px" title="申请审批" :visible.sync="dialogVisible" :close-on-click-modal="false">
		<el-form ref="ruleForm" :model="form" label-width="100px">
			<el-form-item label="审核状态">
				<el-select v-model="form.sale_user_id" placeholder="请选择" @change="handleChange">
					<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
					</el-option>
				</el-select>
			</el-form-item>
            <el-form-item label="备注" prop="remark">
				<el-input v-model="form.remark" type="textarea" :rows="4" placeholder="备注" />
			</el-form-item>
		</el-form>
		<div slot="footer" class="dialog-footer">
			<el-button size="small" @click="dialogVisible = false">取 消</el-button>
			<el-button size="small" type="primary" @click="submit">确 定</el-button>
		</div>
	</el-dialog>
</template>

<script>
	import {
		checkPass,
		checkRefuse
	} from '@/api/user'
	export default {
		// props: ['orderId'],
		props: {
			checkId: {
				type: String,
				default: ''
			}
		},
		data() {
			return {
				form: {
					sale_user_id: '',
					remark: ''
				},
				options: [{
					value: '1',
					label: '审核通过'
				}, {
					value: '2',
					label: '审核拒绝'
				}],
				value: '',
				check_status: '',
				dialogVisible: false
			}
		},
		methods: {
			handleChange(val) {
				console.log(val);
				this.check_status = val
			},
			submit() {
				this.$refs['ruleForm'].validate((valid) => {
					if (valid) {
						// 审核通过
						if(this.check_status==1){
							checkPass({sale_user_id:this.checkId,check_remark:this.form.remark}).then(res=>{
								console.log(res);
								this.dialogVisible=false
								// this.$message({
								// 	type:'success',
								// 	message:res.msg
								// })
							})
						}else{
							// 审核拒绝
							checkRefuse({sale_user_id:this.checkId,check_remark:this.form.remark}).then(res=>{
								console.log(res);
								this.dialogVisible=false
								// this.$message({
								// 	type:'error',
								// 	message:res.msg
								// })
							})
						}
					} else {
						this.$message({
							message: '请检查表单错误',
							type: 'error'
						})
						return false
					}
				})
			}
		}
	}
</script>

<style lang="less" scoped>
</style>
